import instance from "@/services/axios";
/**
 *  加密
 */
import { cryptoPwd } from "@/utils/index";

/**
 * 登录
 * @param {*} timestamp
 * @param {*} param
 * @returns
 */
async function login(username, password) {
    /**
     * 时间戳
     */
    const timestamp = +new Date();
    /**
     * 请求接口
     */
    const { status, message, msg } = await instance.post(
        "login",
        {
            username: username,
            password: cryptoPwd(password, timestamp),
        },
        {
            headers: {
                timestamp,
            },
        }
    );
    return { status, message, msg };
}

/**
 * 放开让外面调用
 */
export default {
    login,
};
